﻿
using System;
using System.Web.UI.WebControls;
using XYTXL.API;
using XYTXL.Data;
using XYTXL.AppCode;

namespace XYTXL.Web.View.UCMangForm
{
    public partial class XBGL : FormUControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }
        }

        /// <summary>
        /// 新增时验证栏目重复
        /// </summary>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyAddForm(string strActionType)
        {
            int TopId = Convert.ToInt32(txtNum.Text);
            xy_xbdm Model = new xy_xbdmB().GetEntity(p =>  p.xbdm == txtName.Text);
            string strMsg = string.Empty;
            if (Model != null)
            {
                strMsg = "此代码已经存在！";
            }
            return strMsg;
        }
        /// <summary>
        /// 修改时验证栏目重复
        /// </summary>
        /// <param name="intFormID"></param>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyUpdateForm(int intFormID)
        {
           
            return "";
        }

        /// <summary>
        /// 重写父类的保存数据方法
        /// </summary>
        /// <param name="intFormID">数据ID</param>
        /// <param name="strActionType">操作类型("ADD":"添加","UPDATE":"修改")</param>
        /// <returns></returns>
        public override bool SaveForm(int intFormID, string strActionType,int pid)
        {
            //执行 父类的方法
            base.SaveForm(intFormID, strActionType);

            //保存数据
            xy_xbdm Model = new xy_xbdmB().GetEntity(d => d.ID == intFormID);
            Model.xbdm = txtName.Text;
            Model.xbmc = txtNum.Text;
            Model.jxxb = ddlSFJXXB.SelectedValue;
            Model.gluser = txtAuthUser.Text;
            Model.glusername = new JH_Auth_UserB().GetUserRealNames(txtAuthUser.Text.ToString().Split(','));

            return new xy_xbdmB().Update(Model);
        }




        public override void initMangerForm(int intFormID, string strActionType)
        {
            base.initMangerForm(intFormID, strActionType);
            xy_xbdm Model = new xy_xbdmB().GetEntity(d => d.ID == intFormID);
            txtName.Text = Model.xbdm;
            txtNum.Text = Model.xbmc;
            txtAuthUser.Text = Model.gluser;
            ddlSFJXXB.SelectedValue = Model.jxxb;

      
        }

    }
}